package com.example.xiaomi.service;

import com.example.xiaomi.entity.topic;
import com.example.xiaomi.mapper.TopicMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TopicServiceImpl implements TopicService {



    @Autowired
    private TopicMapper mapper;

    @Override
    public List<topic> findTopicAccount() {
        List<topic> topicAccount = mapper.findTopicAccount();
        return topicAccount;
    }

    @Override
    public List<topic> findAllTopics(String topic) {
        List<topic> allTopic = mapper.findAllTopics(topic);
        return allTopic;
    }

    @Override
    public List<topic> findAllTopic(String topic) {
        List<topic> topicAll = mapper.findAllTopic(topic);
        return topicAll;
    }


    @Override
    public List<topic> findTopics(String topic){
        List<topic> searchTopic = mapper.findTopics(topic);
        return searchTopic;
    }

    @Override
    public List<topic> findTopicByDate() {
        List<topic> TopicDate = mapper.findTopicByDate();
        return TopicDate;
    }


    @Override
    public PageInfo<topic> findPageTopic(Integer pageNum, Integer pageSize, String topic) {
        PageHelper.startPage(pageNum, pageSize);
        List<topic> lists = mapper.findAllTopics(topic);
        PageInfo<topic> pageInfo = new PageInfo<>(lists);
        return pageInfo;
    }

//    @Override
//    public List<topic> findTopicCount(){
//        List<topic> topicCount = mapper.findTopicByDate();
//        return topicCount;
//    }

}
